package com.sjt.thread;

import java.util.concurrent.locks.LockSupport;

public class ParkAndUnParkTest {
    public static void main(String[] args) throws InterruptedException{
        ParkAndUnParkThread parkAndUnParkThread=new ParkAndUnParkThread();
        parkAndUnParkThread.start();
        LockSupport.unpark(parkAndUnParkThread);
         Thread.sleep(2000);
        LockSupport.unpark(parkAndUnParkThread);//恢复两次
    }
}
class ParkAndUnParkThread extends Thread{
    @Override
    public void run() {
        while (true) {
            System.out.println("继续执行");
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
            LockSupport.park();
        }
    }
}